import axios from 'axios'

export const Login = (count, psw) => (
    fetch(`http://106.12.79.128:666/login/cellphone?phone=${count}&password=${psw}`,{
        withCredentials:true
    }).then(body=>body.json())
    .then(res=>res)                                                                       
)

export const EscLogin=()=>fetch(`http://106.12.79.128:666/logout`,{
    withCredentials:true
})
    .then(body => body.json())

    export const TestLogin=()=>fetch(`http://106.12.79.128:666/login/status`,{
    withCredentials:true
})

// export const TestLogin=()=>axios({
//     url:`http://106.12.79.128:666/login/status`,
//     withCredentials: true 
// })

// export const Login=(count, psw)=>axios({
//     url:`http://106.12.79.128:666/login/cellphone?phone=${count}&password=${psw}`,
//     withCredentials: true 
// })

export const SerachHot = () => fetch('http://106.12.79.128:666/search/hot')
    .then(body => body.json())
    .then(res =>{
        // console.log(res)
        // console.log(res.result)
        return res.result.hots})

    
export const SerachSong = (song) => fetch(`http://106.12.79.128:666/search/suggest?keywords= ${song}`)
.then(body => body.json())


//zhuqingwei
//获取轮播图
export const getBanner = ()=>fetch("http://106.12.79.128:666/banner")
.then(body=>body.json())
.then(res=>res)
 
//获取推荐歌单
export const getRecommend = ()=>fetch("http://106.12.79.128:666/personalized?limit=12")
.then(body=>body.json())
.then(res=>res)

//获取歌单
export const getPlaylist = ()=>fetch("http://106.12.79.128:666/top/playlist?limit=8")
.then(body=>body.json())
.then(res=>res)

//获取歌单列表
export const getLists = ()=>fetch(`http://106.12.79.128:666/top/playlist?limit=9&order=new`)
.then(body=>body.json())
.then(res=>res)

//获取歌曲
export const getDetails = (id)=>fetch(`http://106.12.79.128:666/playlist/detail?id=${id}`)
.then(body=>body.json())
.then(res=>res)
//获取排行榜
export const getRank = ()=>fetch(`http://106.12.79.128:666/toplist/detail`)
.then(body=>body.json())
.then(res=>res.list)
//获取歌曲
export const getsong = (id)=>fetch(`http://106.12.79.128:666/song/url?id=${id}`)
.then(body=>body.json())
.then(res=>res)
//获取歌曲详情
export const getsongInfo = (ids)=>fetch(`http://106.12.79.128:666/song/detail?ids=${ids}`)
.then(body=>body.json())
.then(res=>res)

export const SerachUrl = (id) => fetch(`http://106.12.79.128:666/song/url?id=${id}`)
.then(body => body.json())

export const Single = ( ) => fetch(`http://106.12.79.128:666/top/artists?offset=0&limit=30`)
.then(body => body.json())
.then(res => res)

export const SingleSame = ( name) => fetch(`http://106.12.79.128:666/search/suggest?keywords= ${name}&type=mobile`)
.then(body => body.json())
.then(res => res)
